using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NhaThuocOnline.Entities.Mapping
{
    public class NhaThuocMap : EntityTypeConfiguration<NhaThuoc>
    {
        public NhaThuocMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.TenNhaThuoc)
                .HasMaxLength(100);

            this.Property(t => t.DiaChi)
                .HasMaxLength(255);

            this.Property(t => t.DienThoai)
                .HasMaxLength(20);

            this.Property(t => t.Fax)
                .HasMaxLength(20);

            this.Property(t => t.SoTaiKhoan)
                .HasMaxLength(20);

            this.Property(t => t.TenNganHang)
                .HasMaxLength(100);

            this.Property(t => t.ChiNhanhNganHang)
                .HasMaxLength(100);

            this.Property(t => t.MaSoThue)
                .HasMaxLength(20);

            this.Property(t => t.TenDuocSi)
                .HasMaxLength(100);

            this.Property(t => t.GiayDangKy)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("NhaThuoc");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.TenNhaThuoc).HasColumnName("TenNhaThuoc");
            this.Property(t => t.DiaChi).HasColumnName("DiaChi");
            this.Property(t => t.DienThoai).HasColumnName("DienThoai");
            this.Property(t => t.Fax).HasColumnName("Fax");
            this.Property(t => t.SoTaiKhoan).HasColumnName("SoTaiKhoan");
            this.Property(t => t.TenNganHang).HasColumnName("TenNganHang");
            this.Property(t => t.ChiNhanhNganHang).HasColumnName("ChiNhanhNganHang");
            this.Property(t => t.MaSoThue).HasColumnName("MaSoThue");
            this.Property(t => t.TenDuocSi).HasColumnName("TenDuocSi");
            this.Property(t => t.GiayDangKy).HasColumnName("GiayDangKy");
            this.Property(t => t.NgayCap).HasColumnName("NgayCap");
            this.Property(t => t.TrangThai).HasColumnName("TrangThai");
            this.Property(t => t.UserId).HasColumnName("UserId");
            this.Property(t => t.NgayCapNhat).HasColumnName("NgayCapNhat");

            // Relationships
            this.HasOptional(t => t.UserInfo)
                .WithMany(t => t.NhaThuocs)
                .HasForeignKey(d => d.UserId);

        }
    }
}
